<%@page language="java" pageEncoding="utf-8"%>
<%@page import="java.util.*"%>
<%@page import="dreamtime.dreamnews.news.*"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.sql.*"%>
<%@page import="dreamtime.dreamnews.*"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新闻浏览</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<%      
	 int smallclassid=44;
	 int startNum=0;
	 int listNum=11;
	 int titleNum=20;
	 int modelNum=1;
	 //定义图片长宽
	 int imageHeight=90;
	 int imageWidth=70;
                String idString=request.getParameter("smallclassid");
        if(idString!=null&&idString.matches("[0-9]*[1-9][0-9]*")){
        smallclassid=Integer.parseInt(idString);
        }
                String startString=request.getParameter("startNum");
        if(startString!=null&&startString.matches("[0-9]*[1-9][0-9]*")){
        startNum=Integer.parseInt(startString);
        }
                String listString=request.getParameter("listNum");
        if(listString!=null&&listString.matches("[0-9]*[1-9][0-9]*")){
        listNum=Integer.parseInt(listString);
        }
                String titleString=request.getParameter("titleNum");
        if(titleString!=null&&titleString.matches("[0-9]*[1-9][0-9]*")){
        titleNum=Integer.parseInt(titleString);
        }
                String modelString=request.getParameter("modelNum");
        if(modelString!=null&&modelString.matches("[0-9]*[1-9][0-9]*")){
        modelNum=Integer.parseInt(modelString);
        }
                String heightString=request.getParameter("imageHeight");
        if(heightString!=null&&heightString.matches("[0-9]*[1-9][0-9]*")){
        imageHeight=Integer.parseInt(heightString);
        }
                String widthString=request.getParameter("imageWidth");
        if(widthString!=null&&widthString.matches("[0-9]*[1-9][0-9]*")){
        imageWidth=Integer.parseInt(widthString);
        }
        DBConnection accessconn=new DBConnection();
        Connection conn=null;
        PreparedStatement pstmt=null;
		ResultSet rs=null;	
		try{ 
        conn=accessconn.getConn();
        pstmt=conn.prepareStatement("select newsid,newstitle,newstime,newspicture from news where smallclassid=? and IsImg='yes' order by newsid desc",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
        HashMap     reportNewsMap=LinkNews.getNewsMap(conn,pstmt,rs,smallclassid,startNum,listNum,titleNum);
		ArrayList   reportIdList=(ArrayList)reportNewsMap.get("newsid");
		ArrayList   reportTitleList=(ArrayList)reportNewsMap.get("newstitle");
		ArrayList   reportTimeList=(ArrayList)reportNewsMap.get("newstime");
		ArrayList   reportPictureList=(ArrayList)reportNewsMap.get("newspicture");
%>
<%for(int i=0;i<reportIdList.size();i++){ %>
<td>
<a 
   href="<%=basePath%>automobile/newsContent-<%=(String)reportIdList.get(i)%>.html"
   title="<%=(String)reportTitleList.get(i)%>" target="_blank"  
   onFocus="this.blur()">
<img
	src="<%="../"+(String)reportPictureList.get(i)%>" width="<%=imageWidth%>"
	height="<%=imageHeight%>" alt="<%=(String)reportTitleList.get(i)%>" />
</a>
</td>
<%}%>
<%
  }catch(SQLException se){
  out.print(se.getMessage());
  }finally{
  accessconn.closeResultSet(rs);
  accessconn.closePreparedStatement(pstmt);
  accessconn.closeConnection(conn);
  }
%>
</body>
</html>